package org.fusionide.builder.parsers.cfml.tags;

import org.fusionide.builder.parsers.IParserHandler;
import org.fusionide.builder.parsers.ParserException;
import org.fusionide.builder.parsers.cfml.CFMLTag;


public class Dump extends CFMLTag {
	// <cfdump var="" expand="" label="">

	private String var;

	private String expand;

	private String label;

	public Dump(String attributes, int lineNumber) {
		super(attributes, lineNumber);

		if (attributes == null)
			return;

		this.var = getAttribute("var");
		this.expand = getAttribute("expand");
		this.label = getAttribute("label");
	}

	@Override
	public boolean requiresClosingTag() {
		return false;
	}

	@Override
	public boolean acceptsChildren(CFMLTag tag) {
		return false;
	}

	@Override
	public boolean validate(IParserHandler parserHandler) {
		if (super.validate(parserHandler)) {
			if (var == null || var.equalsIgnoreCase("")) {
				if (parserHandler != null)
					parserHandler.addMarker(new ParserException("<cfdump> Var attribute is required", ParserException.SEVERITY_ERROR, startLine));
				return false;
			}
			return true;
		}
		return false;
	}

	public String getExpand() {
		return expand;
	}

	public void setExpand(String expand) {
		this.expand = expand;
	}

	public String getLabel() {
		return label;
	}

	public void setLabel(String label) {
		this.label = label;
	}

	public String getVar() {
		return var;
	}

	public void setVar(String var) {
		this.var = var;
	}
}
